package com.cxcy.swustlearner.controller;

import com.cxcy.swustlearner.pojo.User;
import com.cxcy.swustlearner.service.UserService;
import common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/users")
public class UsersController {
    @Autowired
    private UserService userService;
    @GetMapping()
    public Result getUsers(@RequestBody User user, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer pagesize) {
        return Result.success(userService.GetAllUsers(user,page,pagesize));
    }
    @PutMapping()
    public Result updateUser(@RequestBody User user) {
        userService.updateUser(user);
        return Result.success("更新成功");
    }
}